import { createManagedDeviceInNode } from 'onvif-rx'

const device = createManagedDeviceInNode({
  deviceUrl: 'http://10.0.0.167:80/onvif/device_service',
  password: 'admin',
  username: '123456'
});

// const device = createManagedDeviceInNode({
//     deviceUrl: 'http://10.0.0.53/onvif/device_service',
//     password: 'admin',
//     username: 'admin123456'
// });

async function test(): Promise<void> {
    const getDeviceInformation = await device.api.Device.GetDeviceInformation().toPromise();
    const getProfiles = await device.api.Media.GetProfiles().toPromise();
    const 
    debugger;
}

test().catch(e=>console.log);

// device.api.Device.GetUsers().toPromise().then(res=> {
//     res.match({ // results are wrapped in a managed object for safer processing
//         ok: success => console.log(success.json), // successful response object
//         fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
//     })
// });



// import { createManagedDeviceInNode,StreamType, TransportProtocol } from '@nger/onvif-rx/src/node'
// import { onvifDevices$ } from 'camera-probe'

// const subscription = onvifDevices$()
// subscription.subscribe(console.log);
// const device = createManagedDeviceInNode({
//     deviceUrl: 'http://10.0.1.100/onvif/device_service',
//     username: 'admin',
//     password: 'admin123456',
// })

// let token = "";

// device.api.Media.GetProfiles()
// .toPromise()
// .then(res => {
//     res.match({ // results are wrapped in a managed object for safer processing
//         ok: success =>{
//             console.log(JSON.stringify(success.json));
//             token = success.json.Profiles[0]['_attributes'].token
//             console.log(token);
//             device.api.Media.GetStreamUri({
//                 Stream:StreamType["RTP-Unicast"],
//                 Transport: {
//                     Protocol: TransportProtocol.TCP
//                 }
//             },token)
//             .toPromise()
//             .then(res => {
//                 res.match({ // results are wrapped in a managed object for safer processing
//                     ok: success =>{
//                         console.log(JSON.stringify(success.json));
//                     } , // successful response object
//                     fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
//                 })
//             }) 
//         } , // successful response object
//         fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
//     })
// }) 

